package com.itheima;

import java.util.TreeSet;

/**
 * @auther Macrydy
 * @date 2020/6/30 10:41
 */
public class TeacherDemo {
    public static void main(String[] args) {
        TreeSet<Teacher> set = new TreeSet<>((o1, o2) -> {
            int result = o1.getAge() - o2.getAge();
            result = result == 0 ? o1.getName().compareTo(o2.getName()) : result;
            return result;
        });

        set.add(new Teacher("zhangsan", 20));
        set.add(new Teacher("zhangsan", 20));
        set.add(new Teacher("lisan", 25));
        set.add(new Teacher("lisi", 27));
        set.add(new Teacher("wangwu", 29));

        System.out.println(set);

    }
}
